package spe.ui.editor.part;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.editparts.AbstractTreeEditPart;
import org.eclipse.ui.IActionFilter;

import spe.model.notation.SPEMDiagram;
import spe.model.spem.NodeElement;
import spe.model.spem.SPEMElement;

public class DiagramOutlineEditPart extends AbstractTreeEditPart implements
PropertyChangeListener, IActionFilter
{
	public DiagramOutlineEditPart(SPEMElement element)
	{
		setModel(element);
	}
	
	@Override
	protected List<AbstractTreeEditPart> getModelChildren()
	{
		SPEMDiagram diagram = (SPEMDiagram) getModel();
		List<AbstractTreeEditPart> childEditPart = new ArrayList<AbstractTreeEditPart>();
		List<NodeElement> childElements = diagram.getElements();
		for(NodeElement e: childElements)
			childEditPart.add(new NodeElementOutlineEditPart(e));
		
		return childEditPart;
	}
	
	public void propertyChange(PropertyChangeEvent evt)
	{
		refreshChildren();
		refreshVisuals();
	}

	@Override
	public boolean testAttribute(Object arg0, String arg1, String arg2) {
		// TODO Auto-generated method stub
		return false;
	}
}
